package www.openteam.com.model.PrdctnMngmnt;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import www.openteam.com.base.BaseModel;
import www.openteam.com.bean.MoneyType;
import www.openteam.com.bean.PayType;
import www.openteam.com.bean.SRCKPlanMsg;
import www.openteam.com.bean.SRCPoduMsg;

/**
 * Created by Administrator on 2019-06-19.
 */

public class SendRCKModel extends BaseModel{

    public void findMoneyType( final MoneyTypeListener listener){
        httpApiService.findMoneyType().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<MoneyType>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        listener.fail(e);
                    }

                    @Override
                    public void onNext(MoneyType data) {
                        listener.success(data);
                    }
                })
        ;
    }

    public void findPayType( final PayTypeListener listener){
        httpApiService.findPayType().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<PayType>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        listener.fail(e);
                    }

                    @Override
                    public void onNext(PayType data) {
                        listener.success(data);
                    }
                })
        ;
    }

    public void findSRCPoduMsg( final PoduMsgListener listener){
        httpApiService.findPoduMsg().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<SRCPoduMsg>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        listener.fail(e);
                    }

                    @Override
                    public void onNext(SRCPoduMsg data) {
                        listener.success(data);
                    }
                })
        ;
    }

    public void findPlanMsg( String code,final PlanMsgListener listener){
        httpApiService.findPlanMsg(code).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<SRCKPlanMsg>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        listener.fail(e);
                    }

                    @Override
                    public void onNext(SRCKPlanMsg data) {
                        listener.success(data);
                    }
                })
        ;
    }

    public interface MoneyTypeListener{
        void success(MoneyType moneyType);

        void fail(Throwable e);
    }

    public interface PayTypeListener{
        void success(PayType Paytype);

        void fail(Throwable e);
    }

    public interface PoduMsgListener{
        void success(SRCPoduMsg srcPoduMsg);

        void fail(Throwable e);
    }

    public interface PlanMsgListener{
        void success(SRCKPlanMsg srckPlanMsg);

        void fail(Throwable e);
    }
}
